package xj.graph2d.app.project;

import java.util.HashMap;
import java.util.Map;

public final class ItemType {

  public static final ItemType Default = new ItemType("Default");

  public static final ItemType UML_Diagram = new ItemType("UML Diagram");

  public static final ItemType UML_Class_Diagram = new ItemType("UML Class Diagram");

  private ItemType(String name) {
    this.name = name;
  }

  @Override
  public String toString() {
    return name;
  }

  static public ItemType toItemType(String name) {
    if ("Default".equals(name)) {
      return Default;
    } else if ("UML Diagram".equals(name)) {
      return UML_Diagram;
    } else if ("UML Class Diagram".equals(name)) {
      return UML_Class_Diagram;
    }
    return null;
  }

  static public String getDefaultExtension(ItemType type) {
    if (type != null) {
      return defaultExtension.get(type);
    }
    return null;
  }

  private final String name;

  protected static final Map<ItemType, String> defaultExtension;

  static {
    defaultExtension = new HashMap<ItemType, String>();
    defaultExtension.put(Default, "dml");
    defaultExtension.put(UML_Class_Diagram, "dml");
    defaultExtension.put(UML_Diagram, "dml");
  }

}
